%% term_Uold_grad_Wold_Psi
function vector_b = term_Uold_grad_Wold_Psi(mesh, fespace, Uold, Wold)
Nb = fespace.Nb;
Nlb = fespace.Nlb;
rows = zeros(Nb,1);
val1 = rows;
flag = 1;
for n = 1:mesh.Ne
    V = mesh.node(mesh.elem(n,:),:);
    [int_points_loc, int_weights_loc] = integral_loc(V, "2d");
    phi = basis_loc(V, int_points_loc(:,1), int_points_loc(:,2), fespace.basis_type, "x");
    phix = basis_loc(V, int_points_loc(:,1), int_points_loc(:,2), fespace.basis_type, "dx");
    phiy = basis_loc(V, int_points_loc(:,1), int_points_loc(:,2), fespace.basis_type, "dy");
    u1 = phi * Uold(fespace.elem(n,:));
    u2 = phi * Uold(fespace.elem(n,:)+Nb);
    w3x = phix * Wold(fespace.elem(n,:));
    w3y = phiy * Wold(fespace.elem(n,:));
    for i = 1:Nlb
        f1 = u1.*w3x.*phi(:,i) + u2.*w3y.*phi(:,i);
        r1 = int_weights_loc * f1;
        rows(flag) = fespace.elem(n,i);
        val1(flag) = r1;
        flag = flag + 1;
    end
end
vector_b = sparse(rows, 1, val1, Nb, 1);
end